﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DiscoveryLogic.DataViz.NetworkDiagram.NetworkData;

namespace DiscoveryLogic.DataViz.NetworkDiagram.LinkerControls
{
    /// <summary>
    /// 
    /// </summary>
    public partial class PersonExplorer : Form
    {
        private Dictionary<string,object> objFieldValues=new Dictionary<string, object>();
        private readonly Network _Network;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="net"></param>
        /// <param name="keyValues"></param>
        public PersonExplorer(Network net, List<string> keyValues)
        {
            this._Network = net;
            InitializeComponent();
            this.ReadEntityData(net,keyValues);
        }

        private void ReadEntityData(Network net, List<string> keys)
        {
            this.objFieldValues=new Dictionary<string, object>();
            DataTable dt = net.SelectByKey(keys);
            if(dt !=null && dt.Rows.Count>0)
            {
                DataRow dr = dt.Rows[0];
                foreach(DataColumn col in dt.Columns)
                {
                    objFieldValues.Add(col.ColumnName, dr[col.ColumnName]);
                }
            }
        }

        private void PersonExplorer_Load(object sender, EventArgs e)
        {
            string nameField = this._Network.NetData.LabelFieldName;
            if (this.objFieldValues != null && this.objFieldValues.ContainsKey(nameField))
                if (this.objFieldValues[nameField] != null)
                    this.txt_PersonName.Text = this.objFieldValues[nameField].ToString();

            this.cbo_EntityType.Items.Clear();
            foreach(EntityType entityType in Enum.GetValues(typeof(EntityType)))
            {
                this.cbo_EntityType.Items.Add(entityType.ToString());
            }

            this.wizard1.SelectedPage = this.introductionPage1;
        }

        private void wizardPage2_BeforeDisplay(object sender, EventArgs e)
        {

        }

 
    }
}
